package com.zhou.utis.config;


import com.zhou.utis.interceptors.TokenInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import javax.annotation.Resource;

/**
 * token的拦截器的配置，拦截什么，放行什么
 */
@Configuration
public class SpringMvcSupport extends WebMvcConfigurationSupport {

    @Resource
    private TokenInterceptor tokenInterceptor;

    /**
     * 拦截器的配置 拦所有 放登录
     *
     * @param registry
     */
    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/admin/code_msg").excludePathPatterns("/admin/login").excludePathPatterns("/swagger-ui.html").excludePathPatterns("/v2/**")
                .excludePathPatterns("/swagger-resources/**").excludePathPatterns("/**");
    }
}

